﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CourseExamples
{
    public class C01_Basics
	{
        public static void Run()
        {
            // 循环
            for (int i = 0; i < 10; i++)
            {
                if (i % 2 == 0)
                    Console.WriteLine("i = " + i.ToString());
            }

            var t1 = DateTime.Now;
            Console.WriteLine("Current time:" + t1);
            int res = 0;
            // how many bytes does a single integer take?

            Console.WriteLine($"size of int: {sizeof(int)}");
            long num_loops = 0;
            while (true)
            {
                res += 1;
                num_loops++;
                if (res == 0)
                {
                    Console.WriteLine("res.sdfasdfsdf=" + res);
                    break;
                }
            }
            var t2 = DateTime.Now;

            int v = 2 ^ 31 - 40;
            for (int i = 0; i < 20; i++)
            {
                Console.WriteLine(v + i);
            }
            // 1 byte = 8 bits
            // 0000 0000 ->  0
            // 0000 0001 ->  1
            // 0000 0010 ->  2
            // 0000 0100 ->  4
            // 0000 1000 ->  8
            // 0000 1100 -> 12
            // 0000 1111 -> 15
            // 1111 1111 -> 255 + 1 -> 0
            // 2^32 
            Console.WriteLine($"Total time: {(t2 - t1).TotalMilliseconds:0} ms.");
            Console.WriteLine($"Total number of loops: {num_loops}, {2 ^ 32}");
        }
    }
}
